#include"Sort.h"

void InsertSort(int* a, int n)
{
	int i = 0;
	int end = 0;
	for (i = 0; i < n - 1; i++)
	{
		end = i;
		int tmp = a[end + 1];
		while (end >= 0)
		{
			if (tmp < a[end])
			{
				a[end + 1] = a[end];
			}
			else
			{
				break;
			}
			end--;
		}
		a[end + 1] = tmp;
	}
}
void ShellSort(int* a, int n)
{
	int gap = 3;
	int end = 0;
	int tmp = 0;
	int i = 0;
	for (i = 0; i < n-gap; i+=gap)
	{
		end = i;
		tmp = a[end + gap];
		while (end>=0)
		{
			if (tmp < a[end])
			{
				a[end] = a[end + gap];
			}
			else
			{
				break;
			}
			end -= gap;
		}
		a[end + gap] = tmp;
	}
}
void PrintArray(int* a, int n)
{
	int i = 0;
	for (i = 0; i < n; i++)
	{
		printf("%d ", a[i]);
	}
	printf("\n");
}
void BubbleSort(int* a, int n)
{
	int i = 0;
	int j = 0;
	for (i = 0; i < n - 1; i++)
	{
		for (j = 0; j < n - i-1; j++)
		{
			if (a[j] > a[j + 1])
			{
				int tmp = a[j];
				a[j] = a[j + 1];
				a[j + 1] = tmp;
			}
		}
	}
}









